package com.example.intermingle.config;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author 绿松石
 * @version V1.0
 * @Title SwaggerConfig
 * @Description Swagger 文档配置
 * @date 2021年08月20日 11:17
 * @since V1.0
 */
@Configurable
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket CreaeRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.intermingle.contrllor"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("接口文档")
                .description("这是一个接口文档的描述")
                .version("2.0")
                .contact(new Contact("嘻嘻","kkjj","123456789"))
                .license("哈哈 ")
                .licenseUrl("http://localhost:8083/swagger-ui.html")
                .build();
    }
}
